#include "signal_handler.h"
#include "main.h"
/*******************************************************************************
  * Function Name: register_signal_handler
  *
  ******************************************************************************/
void register_signal_handler()
{
    signal (SIGINT, signal_handler);
}

/*******************************************************************************
  * Function Name: signal_handler
  *
  ******************************************************************************/
void signal_handler( int signal )
{
	char ch;
	
	printf("\nSignal handler invoked.\n");

	if(signal == SIGINT)
	{
		printf("Are you sure to exit [y or n]?: ");
		ch = getchar();

		if(ch == 'y' || ch == 'Y')
		{
			writeSymbolToFile();
			exit(EXIT_SUCCESS);
		}
		else
		{
			shellPrompt();
		}
	}
}

/*******************************************************************************
 * End of file
 */
